Hi All |
Re: Outputting Baseline Annotation String |
Re: Outputting Baseline Annotation String
You need to escape the problematic characters in the string. You can use the below function for that.
// This function will escape newline (\n) tab (\t) and hyphens (")
// to export them to a tab separated string
// i.e. Hello\n"you"\t will become "Hello\n""You""\t"
// This can be pasted to Excel.
void AddEscapedStringToBuffer (string s, Buffer b) {
// Buffer bResult = create()
int i
bool needEscape = false
if (null s) return
// check if we need to escape the string
if (gListviewEscapeCharacters s) needEscape = true
if ( needEscape ) {
b += "\""
for i in 0:length(s)-1 do {
if ( s[i] == '\"') b += '\"'
b += s[i]
}
b += "\""
} else {
// if not: just add it unescaped ...
b += s
return
}
}
string escapeTabsAndNewlines (string s) {
Buffer v = create()
AddEscapedStringToBuffer (s, v)
string result = stringOf v
delete v
return result
}
|
Re: Outputting Baseline Annotation String Mathias Mamsch - Thu Apr 01 06:36:37 EDT 2010
You need to escape the problematic characters in the string. You can use the below function for that.
// This function will escape newline (\n) tab (\t) and hyphens (")
// to export them to a tab separated string
// i.e. Hello\n"you"\t will become "Hello\n""You""\t"
// This can be pasted to Excel.
void AddEscapedStringToBuffer (string s, Buffer b) {
// Buffer bResult = create()
int i
bool needEscape = false
if (null s) return
// check if we need to escape the string
if (gListviewEscapeCharacters s) needEscape = true
if ( needEscape ) {
b += "\""
for i in 0:length(s)-1 do {
if ( s[i] == '\"') b += '\"'
b += s[i]
}
b += "\""
} else {
// if not: just add it unescaped ...
b += s
return
}
}
string escapeTabsAndNewlines (string s) {
Buffer v = create()
AddEscapedStringToBuffer (s, v)
string result = stringOf v
delete v
return result
}
The regular expression was missing: Regexp gListviewEscapeCharacters = regexp "[\"\\n\\t]"
|
Re: Outputting Baseline Annotation String Mathias Mamsch - Thu Apr 01 06:38:05 EDT 2010 The regular expression was missing: Regexp gListviewEscapeCharacters = regexp "[\"\\n\\t]"
Many thanks to you both for your responses and suggestions, most appreciated. I will try them out. Thanks again |